using System;
using Gadgeteer.Interfaces.Fakes.net4.Properties;
using System.Drawing;

namespace Gadgeteer.Interfaces.Fakes.Framework
{
    public class PictureBuilder
    {
        private Bitmap[] images = new[]
        {
            Resources.Image_01,
            Resources.Image_02,
        };

        private int index = 0;

        private int GetNextIndex()
        {
            index++;
            if (index >= images.Length)
                index = 0;

            return index;
        }

        public Picture NextPicture()
        {
            var bitmap = images[GetNextIndex()];
            
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
            stream.Position = 0;

            var picture = new Gadgeteer.Picture(stream.ToArray(), Picture.PictureEncoding.BMP);

            return picture;
        }
    }
}
